package org.zyx.item.api;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.zyx.item.bo.SpuBo;
import org.zyx.item.entity.Sku;
import org.zyx.item.entity.Spu;
import org.zyx.item.entity.SpuDetail;
import org.zyx.yiyou.common.entity.PageResult;

import java.util.List;

/**
 * @Author: SwordMaple
 * @Date: 2020/9/20  19:51
 * @Description:
 * @Version: 1.0
 */
public interface GoodsApi {

    /**
     * 通过SpuId查询SpuDetail
     * @param spuId
     * @return
     */
    @GetMapping("/spu/detail/{spuId}")
    SpuDetail findSpuDetailById(@PathVariable("spuId") Long spuId);


    /**
     * 根据条件分页查询spu
     * @param key
     * @param saleable
     * @param page
     * @param rows
     * @return
     */
    @GetMapping("/spu/page")
    public PageResult<SpuBo> findSpuByPage(
            @RequestParam(name = "key", required = false) String key,
            @RequestParam(name = "saleable", required = false) Boolean saleable,
            @RequestParam(name = "page", defaultValue = "1")Integer page,
            @RequestParam(name = "rows", defaultValue = "5")Integer rows);

    /**
     * 根据spuId查询skus
     * @param id
     * @return
     */
    @GetMapping("/sku/list")
    public List<Sku> findSkusBySpuId(@RequestParam Long id);

    /**
     * 根据id查询spu
     * @param spuId
     * @return
     */
    @GetMapping("/spu/{id}")
    public Spu findSpuById(@PathVariable("id") Long spuId);

    /**
     * 通过skuId查找sku
     * @param id
     * @return
     */
    @GetMapping("/sku/{id}")
    public Sku querySkuById(@PathVariable("id") Long id);

}
